package com.infitecs.eyas.judge.service;

import com.infitecs.eyas.judge.dao.JudgeDao;
import com.infitecs.eyas.judge.model.ReportRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Demon on 2015/4/28.
 */
@Service("judgeService")
public class JudgeService {
    @Autowired
    private JudgeDao judgeDao;

    public void judgeE10ByJudgeCase1(double vdaf,int caseId) {
        ReportRecord record = judgeDao.judgeE10ByJudgeCase1(vdaf);
        judgeDao.addReportRecord(getValidRecord(record,1,caseId,vdaf));
    }

    public void judgeE10ByJudgeCase2(double vdaf,int caseId) {
        ReportRecord record = judgeDao.judgeE10ByJudgeCase2(vdaf);
        judgeDao.addReportRecord(getValidRecord(record,2,caseId,vdaf));
    }

    public void judgeE15ByJudgeCase2(double qnetAr,int caseId) {
        ReportRecord record = judgeDao.judgeE15ByJudgeCase2(qnetAr/1000);
        judgeDao.addReportRecord(getValidRecord(record,3,caseId,qnetAr));
    }

    public void judgeE7ByJudgeCase2(double E7,int caseId) {
        ReportRecord record = judgeDao.judgeE7ByJudgeCase2(E7);
        judgeDao.addReportRecord(getValidRecord(record,4,caseId,E7));
    }

    public void judgeE3ByJudgeCase2(double mar,int caseId) {
        ReportRecord record = judgeDao.judgeE3ByJudgeCase2(mar);
        judgeDao.addReportRecord(getValidRecord(record,5,caseId,mar));
    }

    public void judgeE8ByJudgeCase2(double E8,int caseId) {
        ReportRecord record = judgeDao.judgeE8ByJudgeCase2(E8);
        judgeDao.addReportRecord(getValidRecord(record,6,caseId,E8));
    }

    public void judgeE54ByJudgeCase2(double st,int caseId) {
        ReportRecord record = judgeDao.judgeE54ByJudgeCase2(st);
        judgeDao.addReportRecord(getValidRecord(record,7,caseId,st));
    }

    public void judgeE57ByJudgeCase3(double rt,int caseId) {
        ReportRecord record = judgeDao.judgeE57ByJudgeCase3(rt);
        judgeDao.addReportRecord(getValidRecord(record,8,caseId,rt));
    }

    public void judgeE80ByJudgeCase4(double kd,int caseId) {
        ReportRecord record = judgeDao.judgeE80ByJudgeCase4(kd);
        judgeDao.addReportRecord(getValidRecord(record,9,caseId,kd));
    }

    public void judgeE21ByJudgeCase5(double hgi,int caseId) {
        ReportRecord record = judgeDao.judgeE21ByJudgeCase5(hgi);
        judgeDao.addReportRecord(getValidRecord(record,10,caseId,hgi));
    }

    public void judgeE23ByJudgeCase6(double ke,int caseId) {
        ReportRecord record = judgeDao.judgeE23ByJudgeCase6(ke);
        judgeDao.addReportRecord(getValidRecord(record,11,caseId,ke));
    }

    public void judgeE24ByJudgeCase6(double al,int caseId) {
        ReportRecord record = judgeDao.judgeE24ByJudgeCase6(al);
        judgeDao.addReportRecord(getValidRecord(record,12,caseId,al));
    }

    public void judgeE85ByJudgeCase7(double rz,int caseId) {
        ReportRecord record = judgeDao.judgeE85ByJudgeCase7(rz);
        judgeDao.addReportRecord(getValidRecord(record,13,caseId,rz));
    }

    public void judgeE50ByJudgeCase8(double kgc,int caseId) {
        ReportRecord record = judgeDao.judgeE50ByJudgeCase8(kgc);
        judgeDao.addReportRecord(getValidRecord(record,14,caseId,kgc));
    }

    public void judgeE51ByJudgeCase9(double hm,int caseId) {
        ReportRecord record = judgeDao.judgeE51ByJudgeCase9(hm);
        judgeDao.addReportRecord(getValidRecord(record,15,caseId,hm));
    }

    public void addReportRecord(ReportRecord reportRecord) {
        judgeDao.addReportRecord(reportRecord);
    }

    public List<ReportRecord> getReportByCaseId(int caseId) {
        return judgeDao.getReportByCaseId(caseId);
    }

    public ReportRecord getValidRecord(ReportRecord record,int itemId,int caseId,double result){
        if(record == null)
            record = new ReportRecord();
        record.setJudgeItemId(itemId);
        record.setCaseId(caseId);
        record.setResult(result);
        return record;
    }

}
